/******************************************************************************
 * @ CompanyName : Copyright (C), 2031,  xx Information Technology Co., Ltd.
 * @ FileName    : event_schedule_test.c
 * @ Descripttion: event schedule demo test source file
 * @ version     : 1.4
 * @ Author      : SunXin
 * @ Date        : 2023-06-05 11:39:26
 * @ LastEditTime: 2023-09-18 20:17:50
 * @ Chargelog   : 1.xxx
 ******************************************************************************/
//说明：构建并测试事件计划的基本功能，产生基本的“创建”“执行”“销毁”过程



/***********************************************************************************/
//                  Header reference           
/***********************************************************************************/
#include "event_schedule_manage.h"
#include "event_schedule_test.h"


/***********************************************************************************/
//                  macro definition           
/***********************************************************************************/
/*debug log开关定义*/
#if((PRINT_MODE_DEF_RTT == PRINT_CONFIG_MODE)&&(LOG_ON == SYSTEM_EVENT_SCHEDULE_MANAGE_LOG_EN))
    #define LOCAL_DEBUG(...)            SEGGER_RTT_printf(0,__VA_ARGS__)
#elif((PRINT_MODE_DEF_UART == PRINT_CONFIG_MODE)&&(LOG_ON == SYSTEM_EVENT_SCHEDULE_MANAGE_LOG_EN))
    #define LOCAL_DEBUG(...)            debug_info(__VA_ARGS__)
#else
    #include <stdio.h>
    #define LOCAL_DEBUG(...)            printf(__VA_ARGS__)
#endif

#define data_malloc         pvPortMalloc
#define data_free           vPortFree

/***********************************************************************************/
//                  variable definition           
/***********************************************************************************/
//CORE事件队列
extern ENUM_ES_EVENT_STATE_T g_m_es_event[];

//CORE计划队列
extern ENUM_ES_SCHEDULE_STATE_T g_m_es_schedule[];

//es api
extern const STRUCT_EVENT_SCHEDULE_API event_sch_api;

//sys api
extern const STRUCT_SYSTEM_INTERNAL_API es_sys_api;


/***********************************************************************************/
//                  variable definition           
/***********************************************************************************/
#ifdef ES_MANAGE_TEST_OPEN
void TestEsEvent1Start(struct STRUCT_ES_EVENT_TARGET* pevent);
void TestEsEvent1Proc(struct STRUCT_ES_EVENT_TARGET* pevent);
void TestEsEvent1Stop(struct STRUCT_ES_EVENT_TARGET* pevent);
void TestEsEvent2Start(struct STRUCT_ES_EVENT_TARGET* pevent);
void TestEsEvent2Proc(struct STRUCT_ES_EVENT_TARGET* pevent);
void TestEsEvent2Stop(struct STRUCT_ES_EVENT_TARGET* pevent);
void TestEsEvent3Start(struct STRUCT_ES_EVENT_TARGET* pevent);
void TestEsEvent3Proc(struct STRUCT_ES_EVENT_TARGET* pevent);
void TestEsEvent3Stop(struct STRUCT_ES_EVENT_TARGET* pevent);
void TestEsEvent4Start(struct STRUCT_ES_EVENT_TARGET* pevent);
void TestEsEvent4Proc(struct STRUCT_ES_EVENT_TARGET* pevent);
void TestEsEvent4Stop(struct STRUCT_ES_EVENT_TARGET* pevent);

void TestEsSche1Proc(struct STRUCT_ES_SCHEDULE_TARGET *psch);
void TestEsSche1Stop(struct STRUCT_ES_SCHEDULE_TARGET *psch);
void TestEsSche2Proc(struct STRUCT_ES_SCHEDULE_TARGET *psch);
void TestEsSche2Stop(struct STRUCT_ES_SCHEDULE_TARGET *psch);
void TestEsSche3Proc(struct STRUCT_ES_SCHEDULE_TARGET *psch);
void TestEsSche3Stop(struct STRUCT_ES_SCHEDULE_TARGET *psch);
void TestEsSche4Proc(struct STRUCT_ES_SCHEDULE_TARGET *psch);
void TestEsSche4Stop(struct STRUCT_ES_SCHEDULE_TARGET *psch);

void ExtEsManageDebugPrintAllEs(void);


//==========================event part====================================
//事件目标执行方式
typedef enum 
{
    e_ES_EVENT_TEST_NONE,             //test 未在执行中
    e_ES_EVENT_TEST_RUNNING,          //test 在执行中
} ENU_ES_EVENT_TEST_S;


//事件目标结构体
typedef struct
{
    ENU_ES_EVENT_TEST_S m_enuState;   //测试状态
    uint32_t m_u32RunCount;           //测试时长，单位秒
}STU_ES_EVENT_TEST_T;

STU_ES_EVENT_TEST_T g_m_es_test = 
{
    e_ES_EVENT_TEST_NONE,
    0,
};


//----模拟任务1-----
STRUCT_ES_EVENT_TARGET_T es_test_target1 = 
{
    true,
    e_ES_EVENT_TYPE_TEST_01,
    e_ES_EVENT_OP_LOOP,
    0,
    0,
    0,
    NULL,
    TestEsEvent1Start,
    TestEsEvent1Proc,
    NULL,
    TestEsEvent1Stop,
};

void TestEsEvent1Start(struct STRUCT_ES_EVENT_TARGET* pevent)
{
    LOCAL_DEBUG("ES_M_TEST::----TEST EVENT-1 START----\r\n");
}

void TestEsEvent1Proc(struct STRUCT_ES_EVENT_TARGET* pevent)
{
    LOCAL_DEBUG("ES_M_TEST::----TEST EVENT-1 PROC----\r\n");
    LOCAL_DEBUG("ES_M_TEST::----type = %d----\r\n",pevent->m_enuType);
    LOCAL_DEBUG("ES_M_TEST::----content len = %d----\r\n",pevent->content_len);
}

void TestEsEvent1Stop(struct STRUCT_ES_EVENT_TARGET* pevent)
{
    LOCAL_DEBUG("ES_M_TEST::----TEST EVENT-1 STOP----\r\n");
}

//----模拟任务2----
STRUCT_ES_EVENT_TARGET_T es_test_target2 = 
{
    true,
    e_ES_EVENT_TYPE_TEST_02,
    e_ES_EVENT_OP_LOOP,
    0,
    0,
    0,
    NULL,
    TestEsEvent2Start,
    TestEsEvent2Proc,
    NULL,
    TestEsEvent2Stop,
};

void TestEsEvent2Start(struct STRUCT_ES_EVENT_TARGET* pevent)
{
    LOCAL_DEBUG("ES_M_TEST::----TEST EVENT-2 START----\r\n");
}

void TestEsEvent2Proc(struct STRUCT_ES_EVENT_TARGET* pevent)
{
    LOCAL_DEBUG("ES_M_TEST::----TEST EVENT-2 PROC----\r\n");
    LOCAL_DEBUG("ES_M_TEST::----type = %d----\r\n",pevent->m_enuType);
    LOCAL_DEBUG("ES_M_TEST::----content len = %d----\r\n",pevent->content_len);
}

void TestEsEvent2Stop(struct STRUCT_ES_EVENT_TARGET* pevent)
{
    LOCAL_DEBUG("ES_M_TEST::----TEST EVENT-2 STOP----\r\n");
}

//----模拟任务3----
STRUCT_ES_EVENT_TARGET_T es_test_target3 = 
{
    true,
    e_ES_EVENT_TYPE_TEST_03,
    e_ES_EVENT_OP_LOOP,
    0,
    0,
    0,
    NULL,
    TestEsEvent3Start,
    TestEsEvent3Proc,
    NULL,
    TestEsEvent3Stop,
};

void TestEsEvent3Start(struct STRUCT_ES_EVENT_TARGET* pevent)
{
    LOCAL_DEBUG("ES_M_TEST::----TEST EVENT-3 START----\r\n");
}

void TestEsEvent3Proc(struct STRUCT_ES_EVENT_TARGET* pevent)
{
    LOCAL_DEBUG("ES_M_TEST::----TEST EVENT-3 PROC----\r\n");
    LOCAL_DEBUG("ES_M_TEST::----type = %d----\r\n",pevent->m_enuType);
    LOCAL_DEBUG("ES_M_TEST::----content len = %d----\r\n",pevent->content_len);
}

void TestEsEvent3Stop(struct STRUCT_ES_EVENT_TARGET* pevent)
{
    LOCAL_DEBUG("ES_M_TEST::----TEST EVENT=-3 STOP----\r\n");
}


//----模拟任务4----
STRUCT_ES_EVENT_TARGET_T es_test_target4 = 
{
    true,
    e_ES_EVENT_TYPE_TEST_04,
    e_ES_EVENT_OP_ONCE,
    0,
    0,
    0,
    NULL,
    TestEsEvent4Start,
    TestEsEvent4Proc,
    NULL,
    TestEsEvent4Stop,
};


void TestEsEvent4Start(struct STRUCT_ES_EVENT_TARGET* pevent)
{
    LOCAL_DEBUG("ES_M_TEST::----TEST EVENT-4 START----utc:%d\r\n",es_sys_api.get_utc());
}

void TestEsEvent4Proc(struct STRUCT_ES_EVENT_TARGET* pevent)
{
    LOCAL_DEBUG("ES_M_TEST::----TEST EVENT-4 PROC----\r\n");
    LOCAL_DEBUG("ES_M_TEST::----type = %d----\r\n",pevent->m_enuType);
    LOCAL_DEBUG("ES_M_TEST::----content len = %d----\r\n",pevent->content_len);
}

void TestEsEvent4Stop(struct STRUCT_ES_EVENT_TARGET* pevent)
{
    LOCAL_DEBUG("ES_M_TEST::----TEST EVENT-4 STOP----utc:%d\r\n",es_sys_api.get_utc());
}

 /*****************************************************************************
  * 函 数 名  :  EsManageEventTestStart
  * 函数功能  :  test 开始
  * 输入参数  :
  * 返 回 值  : 
 *****************************************************************************/
 void EsManageEventTestStart(void)
 {
     if(e_ES_EVENT_TEST_NONE == g_m_es_test.m_enuState)
     {
         LOCAL_DEBUG("ES_M_TEST::EsManageEventTestStart\r\n");
         g_m_es_test.m_enuState = e_ES_EVENT_TEST_RUNNING;
         g_m_es_test.m_u32RunCount = 0;
         event_sch_api.event_create(&es_test_target1,e_ES_PRIORITY_HIGH);
         event_sch_api.event_create(&es_test_target2,e_ES_PRIORITY_LOW);
         event_sch_api.event_create(&es_test_target3,e_ES_PRIORITY_MID);
         event_sch_api.event_create(&es_test_target4,e_ES_PRIORITY_LOW);
     }
     else
     {
         LOCAL_DEBUG("ES_M_TEST::TEST FUNC IS RUNNIG!!!\r\n");
     }
 }
 
 
 /*****************************************************************************
  * 函 数 名  :  EsManageEventTestProc
  * 函数功能  :  test 循环执行
  * 输入参数  :
  * 返 回 值  : 
 *****************************************************************************/
 void EsManageEventTestProc(void)
 {
     if(e_ES_EVENT_TEST_RUNNING == g_m_es_test.m_enuState)
     {
         g_m_es_test.m_u32RunCount ++;
         //LOCAL_DEBUG("ES_M_TEST::TEST COUNT = %d!!!\r\n",g_m_es_test.m_u32RunCount);
     }
 }
 
 /*****************************************************************************
  * 函 数 名  :  EsManageEventTestEnd
  * 函数功能  :  test 结束
  * 输入参数  :
  * 返 回 值  : 
 *****************************************************************************/
 void EsManageEventTestEnd(void)
 {
     if(e_ES_EVENT_TEST_RUNNING == g_m_es_test.m_enuState)
     {
         LOCAL_DEBUG("ES_M_TEST::EsManageEventTestEnd\r\n");
         g_m_es_test.m_enuState = e_ES_EVENT_TEST_NONE;
         g_m_es_test.m_u32RunCount = 0;
         event_sch_api.event_del_block(es_test_target1.m_enuType);
         event_sch_api.event_del_no_block(es_test_target2.m_enuType);
         event_sch_api.event_del_no_block(es_test_target3.m_enuType);
         event_sch_api.event_del_no_block(es_test_target4.m_enuType);
     }
     else
     {
         LOCAL_DEBUG("ES_M_TEST::TEST FUNC IS NOT RUNNIG!!!\r\n");
     }
 }

#endif

#ifdef SHELL_OPEN //预编译选项中定义
//xshell 调试代码
 /*****************************************************************************
 * 函 数 名  :  CmdTestForEsManageEventStart
 * 函数功能  : 测试命令开始入口函数
 * 输入参数  : u32Argc    命令参数字符串CmdTest
               **ppcArgv  每个参数指针
 * 输出参数  : 无
 * 返 回 值  : LsRet
 * 注    意  : 
*****************************************************************************/
LsRet CmdTestForEsManageEventStart(uint32_t u32Argc, char **ppcArgv)
{
    LOCAL_DEBUG("ES_M_TEST::====ES EVENT TEST START====\r\n");
    #ifdef ES_MANAGE_TEST_OPEN
    EsManageEventTestStart();
    #else
    LOCAL_DEBUG("ES_M_TEST::TEST EVENT FUNC NOT OPEN!!!\r\n");
    LOCAL_DEBUG("ES_M_TEST::====ES EVENT TEST END====\r\n");
    #endif
    
    return 0;
}

/*****************************************************************************
 * 函 数 名  :  CmdTestForEsManageEventStop
 * 函数功能  : 测试命令结束入口函数
 * 输入参数  : u32Argc    命令参数字符串CmdTest
               **ppcArgv  每个参数指针
 * 输出参数  : 无
 * 返 回 值  : LsRet
 * 注    意  : 
*****************************************************************************/
LsRet CmdTestForEsManageEventStop(uint32_t u32Argc, char **ppcArgv)
{
    LOCAL_DEBUG("ES_M_TEST::====ES EVENT TEST STOP====\r\n");
    #ifdef ES_MANAGE_TEST_OPEN
    EsManageEventTestEnd();
    #else
    LOCAL_DEBUG("ES_M_TEST::TEST EVENT FUNC NOT OPEN!!!\r\n");
    LOCAL_DEBUG("ES_M_TEST::====ES EVENT TEST END====\r\n");
    #endif
    
    return 0;
}


/*****************************************************************************
 * 函 数 名  :  CmdTestForEsManageALLObj
 * 函数功能  : 打印有的当前调度器中的对象
 * 输入参数  : u32Argc    命令参数字符串CmdTest
               **ppcArgv  每个参数指针
 * 输出参数  : 无
 * 返 回 值  : LsRet
 * 注    意  : 
*****************************************************************************/
LsRet CmdTestForEsManageALLObj(uint32_t u32Argc, char **ppcArgv)
{
    LOCAL_DEBUG("ES_M_TEST::====ALL ES OBJ====\r\n");
    ExtEsManageDebugPrintAllEs();
    
    return 0;
}



#endif

//==========================计划部分====================================
#ifdef ES_MANAGE_TEST_OPEN

//计划目标执行方式
typedef enum 
{
    e_ES_SCHE_TEST_NONE,             //test 未在执行中
    e_ES_SCHE_TEST_RUNNING,          //test 在执行中
} ENU_ES_SCHE_TEST_S;


//计划目标结构体
typedef struct
{
    ENU_ES_SCHE_TEST_S m_enuState;   //测试状态
    uint32_t m_u32RunCount;          //测试时长，单位秒
}STU_ES_SCHE_TEST_T;

STU_ES_SCHE_TEST_T g_m_sche_test = 
{
    e_ES_SCHE_TEST_NONE,
    0,
};


//----模拟计划1-----
STRUCT_ES_SCHEDULE_TARGET_T sche_test_target1;
/* 
{
    .m_blValid = true,
    .m_blSwitch = true,
    .m_enuType = e_ES_SCHEDULE_TYPE_TEST_01,
    .m_enuOP = e_ES_SCHEDULE_OP_ONCE,
    {
        .m_blInvertValid = false,
        .u32SetOpInvertSec = 0,
        .m_blStartStopSetValid = true,
        .u8StartH = 0,
        .u8StartM = 0,
        .u8StartS = 0,
        .u8EndH = 23,
        .u8EndM = 59,
        .u8EndS = 59,
        .m_blDaySetValid = true,
        .u32SetDay = 0x7FFFFFFF,
        .m_blWeekDaySetValid = false,
        .uni_SetWeekDay = {0xff,0},
        .m_blMonthSetValid = true,
        .uni_SetMonth = {
            .m_struMonthSet = 0xfff,
            .m_u16MonthSetValue = 0x00},
        true,
        2020,
    },
    {0},
    NULL,
    NULL,
    TestEsSche1Proc,
    NULL,
    TestEsSche1Stop,
    NULL,
    NULL,
};
*/
void TestEsSche1Proc(struct STRUCT_ES_SCHEDULE_TARGET *psch)
{
    LOCAL_DEBUG("ES_M_TEST::----TEST SCHE-1 PROC----\r\n");
}

void TestEsSche1Stop(struct STRUCT_ES_SCHEDULE_TARGET *psch)
{
    LOCAL_DEBUG("ES_M_TEST::----TEST SCHE-1 STOP----\r\n");
}

//----模拟计划2----
STRUCT_ES_SCHEDULE_TARGET_T sche_test_target2;
/*
{
    true,
    true,
    e_ES_SCHEDULE_TYPE_TEST_02,
    e_ES_SCHEDULE_OP_ALL,
    {
        true,
        5,
        false,
        0,
        0,
        0,
        0,
        0,
        0,
        false,
        0,
        false,
        {0},
        false,
        {0},
        false,
        0,
    },
    {0},
    NULL,
    NULL,
    TestEsSche2Proc,
    NULL,
    TestEsSche2Stop,
    NULL,
    NULL,
};*/

void TestEsSche2Proc(struct STRUCT_ES_SCHEDULE_TARGET *psch)
{
    LOCAL_DEBUG("ES_M_TEST::----TEST SCHE-2 PROC----\r\n");
}

void TestEsSche2Stop(struct STRUCT_ES_SCHEDULE_TARGET *psch)
{
    LOCAL_DEBUG("ES_M_TEST::----TEST SCHE-2 STOP----\r\n");
}

//----模拟计划3----
STRUCT_ES_SCHEDULE_TARGET_T sche_test_target3;
/*
{
    true,
    true,
    e_ES_SCHEDULE_TYPE_TEST_03,
    e_ES_SCHEDULE_OP_ALL,
    {
        true,
        10,
        false,
        0,
        0,
        0,
        0,
        0,
        0,
        false,
        0,
        false,
        {0},
        false,
        {0},
        false,
        0,
    },
    {0},
    NULL,
    NULL,
    TestEsSche3Proc,
    NULL,
    TestEsSche3Stop,
    NULL,
    NULL,
};*/

void TestEsSche3Proc(struct STRUCT_ES_SCHEDULE_TARGET *psch)
{
    LOCAL_DEBUG("ES_M_TEST::----TEST SCHE-3 PROC----\r\n");
}

void TestEsSche3Stop(struct STRUCT_ES_SCHEDULE_TARGET *psch)
{
    LOCAL_DEBUG("ES_M_TEST::----TEST SCHE=-3 STOP----\r\n");
}


//----模拟任务4----
STRUCT_ES_SCHEDULE_TARGET_T sche_test_target4;
/*
{
    true,
    true,
    e_ES_SCHEDULE_TYPE_TEST_04,
    e_ES_SCHEDULE_OP_ONCE,
    {
        false,
        0,
        true,
        12,
        0,
        0,
        12,
        0,
        5,
        true,
        0x7FFFFFFF,
        false,
        {0},
        true,
        {0xfff,0x00},
        true,
        2020,
    },
    {0},
    NULL,
    NULL,
    TestEsSche4Proc,
    NULL,
    TestEsSche4Stop,
    NULL,
    NULL,
};
*/

void TestEsSche4Proc(struct STRUCT_ES_SCHEDULE_TARGET *psch)
{
    LOCAL_DEBUG("ES_M_TEST::----TEST SCHE-4 PROC----\r\n");
}

void TestEsSche4Stop(struct STRUCT_ES_SCHEDULE_TARGET *psch)
{
    LOCAL_DEBUG("ES_M_TEST::----TEST SCHE-4 STOP----utc:%d\r\n",es_sys_api.get_utc());
}

 /*****************************************************************************
  * 函 数 名  :  EsManageScheTestStart
  * 函数功能  :  test 开始
  * 输入参数  :
  * 返 回 值  : 
 *****************************************************************************/
 void EsManageScheTestStart(void)
 {
     if(e_ES_SCHE_TEST_NONE == g_m_sche_test.m_enuState)
     {
         LOCAL_DEBUG("ES_M_TEST::EsManageScheTestStart\r\n");
         g_m_sche_test.m_enuState = e_ES_SCHE_TEST_RUNNING;
         g_m_sche_test.m_u32RunCount = 0;
         event_sch_api.sch_create(&sche_test_target1,e_ES_PRIORITY_HIGH);
         event_sch_api.sch_create(&sche_test_target2,e_ES_PRIORITY_LOW);
         event_sch_api.sch_create(&sche_test_target3,e_ES_PRIORITY_MID);
         event_sch_api.sch_create(&sche_test_target4,e_ES_PRIORITY_LOW);
     }
     else
     {
         LOCAL_DEBUG("ES_M_TEST::TEST SCHE FUNC IS RUNNIG!!!\r\n");
     }
 }
 
 
 /*****************************************************************************
  * 函 数 名  :  EsManageScheTestProc
  * 函数功能  :  test 循环执行
  * 输入参数  :
  * 返 回 值  : 
 *****************************************************************************/
 void EsManageScheTestProc(void)
 {
     if(e_ES_SCHE_TEST_RUNNING == g_m_sche_test.m_enuState)
     {
         g_m_sche_test.m_u32RunCount ++;
         //LOCAL_DEBUG("ES_M_TEST::TEST COUNT = %d!!!\r\n",g_m_es_test.m_u32RunCount);
     }
 }
 
 /*****************************************************************************
  * 函 数 名  :  EsManageScheTestEnd
  * 函数功能  :  test 结束
  * 输入参数  :
  * 返 回 值  : 
 *****************************************************************************/
 void EsManageScheTestEnd(void)
 {
     if(e_ES_SCHE_TEST_RUNNING == g_m_sche_test.m_enuState)
     {
         LOCAL_DEBUG("ES_M_TEST::EsManageScheTestEnd\r\n");
         g_m_sche_test.m_enuState = e_ES_SCHE_TEST_NONE;
         g_m_sche_test.m_u32RunCount = 0;
         event_sch_api.sch_del_block(sche_test_target1.m_enuType);
         event_sch_api.sch_del_no_block(sche_test_target2.m_enuType);
         event_sch_api.sch_del_no_block(sche_test_target3.m_enuType);
         event_sch_api.sch_del_no_block(sche_test_target4.m_enuType);   
     }
     else
     {
         LOCAL_DEBUG("ES_M_TEST::TEST SCHE FUNC IS NOT RUNNIG!!!\r\n");
     }
 }

/*****************************************************************************
 * 函 数 名  :  ExtEsManageDebugPrintAllEs
 * 函数功能  :  测试接口：打印所有事件队列
 * 输入参数  :  无
 * 返 回 值  :  无
*****************************************************************************/
void ExtEsManageDebugPrintAllEs(void)
{
    uint8_t count_num = 0;
    LOCAL_DEBUG("ES_M::ExtEs--output--EVENT \r\n");
    for(uint8_t i =0 ;i<ES_EVENT_QUEUE_MAX_NUM;i++)
    {
        if(false == g_m_es_event[i].m_blIsEmpty)
        {
            count_num++;
            //LOCAL_DEBUG("ES_M::[%d] event type = %d\r\n",i,g_m_es_event[i].m_enuTarget.m_enuType);
            switch(g_m_es_event[i].m_enuTarget.m_enuType)
            {
                case e_ES_EVENT_TYPE_NONE:
                    LOCAL_DEBUG("ES_M::[%d] event type = e_ES_EVENT_TYPE_NONE \r\n",i);
                    break;
                case e_ES_EVENT_TYPE_TEST_01:
                    LOCAL_DEBUG("ES_M::[%d] event type = e_ES_EVENT_TYPE_TEST_01 \r\n",i);
                    break;
                case e_ES_EVENT_TYPE_TEST_02:
                    LOCAL_DEBUG("ES_M::[%d] event type = e_ES_EVENT_TYPE_TEST_02 \r\n",i);
                    break;
                case e_ES_EVENT_TYPE_TEST_03:
                    LOCAL_DEBUG("ES_M::[%d] event type = e_ES_EVENT_TYPE_TEST_03 \r\n",i);
                    break;
                case e_ES_EVENT_TYPE_TEST_04:
                    LOCAL_DEBUG("ES_M::[%d] event type = e_ES_EVENT_TYPE_TEST_04 \r\n",i);
                    break;
                case e_ES_EVENT_TYPE_TEST_05:
                    LOCAL_DEBUG("ES_M::[%d] event type = e_ES_EVENT_TYPE_TEST_05 \r\n",i);
                    break;
                default:
                    LOCAL_DEBUG("ES_M::[%d] event type = error type \r\n",i);
                    break;
            }
            LOCAL_DEBUG("ES_M::[%d] event op type = %d\r\n",i,g_m_es_event[i].m_enuTarget.m_enuOP);
            LOCAL_DEBUG("ES_M::[%d] event set time = %d\r\n",i,g_m_es_event[i].m_enuTarget.m_u32SetTimeLong);
            LOCAL_DEBUG("ES_M::[%d] event priority = %d\r\n",i,g_m_es_event[i].m_enuPriority);
            LOCAL_DEBUG("ES_M::[%d] event state = %d\r\n",i,g_m_es_event[i].m_enuState);
            LOCAL_DEBUG("ES_M::[%d] event run time = %d\r\n",i,g_m_es_event[i].m_u32OpTimeSecCount);
        }
    }
    LOCAL_DEBUG("ES_M::ExtEs--output--EVENT num = %d\r\n",count_num);
    LOCAL_DEBUG("ES_M::ExtEs--output--SCHEDULE \r\n");
    count_num = 0;
    for(uint8_t i =0 ;i<ES_SCHEDULE_QUEUE_MAX_NUM;i++)
    {
        if(false == g_m_es_schedule[i].m_blIsEmpty)
        {
            //LOCAL_DEBUG("ES_M::[%d] schedule target type = %d\r\n",i,g_m_es_schedule[i].m_enuTarget.m_enuType);
            switch(g_m_es_schedule[i].m_enuTarget.m_enuType)
            {
                case e_ES_SCHEDULE_TYPE_NONE:
                    LOCAL_DEBUG("ES_M::[%d] schedule type = e_ES_SCHEDULE_TYPE_NONE \r\n",i);
                    break;
                case e_ES_SCHEDULE_TYPE_SLEEP_SPO2_SWITCH:
                    LOCAL_DEBUG("ES_M::[%d] schedule type = e_ES_SCHEDULE_TYPE_SLEEP_SPO2_SWITCH \r\n",i);
                    break;
                case e_ES_SCHEDULE_TYPE_TEST_01:
                    LOCAL_DEBUG("ES_M::[%d] schedule type = e_ES_SCHEDULE_TYPE_TEST_01 \r\n",i);
                    break;
                case e_ES_SCHEDULE_TYPE_TEST_02:
                    LOCAL_DEBUG("ES_M::[%d] schedule type = e_ES_SCHEDULE_TYPE_TEST_02 \r\n",i);
                    break;
                case e_ES_SCHEDULE_TYPE_TEST_03:
                    LOCAL_DEBUG("ES_M::[%d] schedule type = e_ES_SCHEDULE_TYPE_TEST_03 \r\n",i);
                    break;
                case e_ES_SCHEDULE_TYPE_TEST_04:
                    LOCAL_DEBUG("ES_M::[%d] schedule type = e_ES_SCHEDULE_TYPE_TEST_04 \r\n",i);
                    break;
                case e_ES_SCHEDULE_TYPE_TEST_05:
                    LOCAL_DEBUG("ES_M::[%d] schedule type = e_ES_SCHEDULE_TYPE_TEST_05 \r\n",i);
                    break;
                default:
                    LOCAL_DEBUG("ES_M::[%d] schedule type = error type \r\n",i);
                    break;
            }
            LOCAL_DEBUG("ES_M::[%d] schedule target op type = %d\r\n",i,g_m_es_schedule[i].m_enuTarget.m_enuOP);
            LOCAL_DEBUG("ES_M::[%d] schedule target vaild = %d\r\n",i,g_m_es_schedule[i].m_enuTarget.m_blValid);
            LOCAL_DEBUG("ES_M::[%d] schedule target switch = %d\r\n",i,g_m_es_schedule[i].m_enuTarget.m_blSwitch);

            if(true == g_m_es_schedule[i].m_enuTarget.m_struSetTime.m_blInvertValid)
            {
                LOCAL_DEBUG("ES_M::[%d] target invert time = %d\r\n",i,g_m_es_schedule[i].m_enuTarget.m_struSetTime.u32SetOpInvertSec);
            }
            if(true == g_m_es_schedule[i].m_enuTarget.m_struSetTime.m_blStartStopSetValid)
            {
                LOCAL_DEBUG("ES_M::[%d] target start hour = %d\r\n",i,g_m_es_schedule[i].m_enuTarget.m_struSetTime.u8StartH);
                LOCAL_DEBUG("ES_M::[%d] target start min = %d\r\n",i,g_m_es_schedule[i].m_enuTarget.m_struSetTime.u8StartM);
                LOCAL_DEBUG("ES_M::[%d] target start sec = %d\r\n",i,g_m_es_schedule[i].m_enuTarget.m_struSetTime.u8StartS);
                LOCAL_DEBUG("ES_M::[%d] target end hour = %d\r\n",i,g_m_es_schedule[i].m_enuTarget.m_struSetTime.u8EndH);
                LOCAL_DEBUG("ES_M::[%d] target end min = %d\r\n",i,g_m_es_schedule[i].m_enuTarget.m_struSetTime.u8EndM);
                LOCAL_DEBUG("ES_M::[%d] target end sec = %d\r\n",i,g_m_es_schedule[i].m_enuTarget.m_struSetTime.u8EndS);
            }
            if(true == g_m_es_schedule[i].m_enuTarget.m_struSetTime.m_blDaySetValid)
            {
                LOCAL_DEBUG("ES_M::[%d] target op day = 0x%0x\r\n",i,g_m_es_schedule[i].m_enuTarget.m_struSetTime.u32SetDay);
            }
            if(true == g_m_es_schedule[i].m_enuTarget.m_struSetTime.m_blWeekDaySetValid)
            {
                LOCAL_DEBUG("ES_M::[%d] target op weekday = 0x%0x\r\n",i,g_m_es_schedule[i].m_enuTarget.m_struSetTime.uni_SetWeekDay.m_u8WeekSetValue);
            }
            if(true == g_m_es_schedule[i].m_enuTarget.m_struSetTime.m_blMonthSetValid)
            {
                LOCAL_DEBUG("ES_M::[%d] target op month = 0x%0x\r\n",i,g_m_es_schedule[i].m_enuTarget.m_struSetTime.uni_SetMonth.m_u16MonthSetValue);
            }
            if(true == g_m_es_schedule[i].m_enuTarget.m_struSetTime.m_blYearSetValid)
            {
                LOCAL_DEBUG("ES_M::[%d] target op year = %0d\r\n",i,g_m_es_schedule[i].m_enuTarget.m_struSetTime.u16SetYear);
            }
            LOCAL_DEBUG("ES_M::[%d] schedule priority = %d\r\n",i,g_m_es_schedule[i].m_enuPriority);
            LOCAL_DEBUG("ES_M::[%d] schedule state = %d\r\n",i,g_m_es_schedule[i].m_enuState);
            LOCAL_DEBUG("ES_M::[%d] schedule run time = %d\r\n",i,g_m_es_schedule[i].m_u32OpTimeSecCount);
        }
    }
    LOCAL_DEBUG("ES_M::ExtEs--output--SCHEDULE num = %d\r\n",count_num);
}

#endif


#ifdef SHELL_OPEN //预编译选项中定义
//xshell 调试代码

 /*****************************************************************************
 * 函 数 名  :  CmdTestForEsManageScheStart
 * 函数功能  : 测试命令开始入口函数(计划测试开始)
 * 输入参数  : u32Argc    命令参数字符串CmdTest
               **ppcArgv  每个参数指针
 * 输出参数  : 无
 * 返 回 值  : LsRet
 * 注    意  : 
*****************************************************************************/
LsRet CmdTestForEsManageScheStart(uint32_t u32Argc, char **ppcArgv)
{
    LOCAL_DEBUG("ES_M_TEST::====ES SCHE TEST START====\r\n");
    #ifdef ES_MANAGE_TEST_OPEN
    EsManageScheTestStart();
    #else
    LOCAL_DEBUG("ES_M_TEST::TEST SCHE FUNC NOT OPEN!!!\r\n");
    LOCAL_DEBUG("ES_M_TEST::====ES SCHE TEST END====\r\n");
    #endif
    
    return 0;
}

/*****************************************************************************
 * 函 数 名  :  CmdTestForEsManageScheStop
 * 函数功能  : 测试命令结束入口函数(计划测试结束)
 * 输入参数  : u32Argc    命令参数字符串CmdTest
               **ppcArgv  每个参数指针
 * 输出参数  : 无
 * 返 回 值  : LsRet
 * 注    意  : 
*****************************************************************************/
LsRet CmdTestForEsManageScheStop(uint32_t u32Argc, char **ppcArgv)
{
    LOCAL_DEBUG("ES_M_TEST::====ES SCHE TEST STOP====\r\n");
    #ifdef ES_MANAGE_TEST_OPEN
    EsManageScheTestEnd();
    #else
    LOCAL_DEBUG("ES_M_TEST::TEST SCHE FUNC NOT OPEN!!!\r\n");
    LOCAL_DEBUG("ES_M_TEST::====ES SCHE TEST END====\r\n");
    #endif
    
    return 0;
}
#endif

/*****************************************************************************/

